import json
import services.service_old as old
import services.service_admin as admin
import services.service_volunteer as vol
import os


def getImgs(role, ID):
    data = {}
    if role == 'old':
        data = old.getById_withoutMapping(ID)
    elif role == 'admin':
        data = admin.getById_withoutMapping(ID)
    else:
        data = vol.getById_withoutMapping(ID)
    imgDir = data.__dict__['profile_photo']
    basedir = os.path.abspath(os.path.dirname(__file__))
    dir = str(basedir) + str(imgDir)
    print(dir)
    return dir


def saveImgPath(role, ID, filePath):
    if role == 'old':
        service = old.update
    elif role == 'admin':
        service = admin.update
    else:
        service = vol.update
    print(filePath)
    service({'ID': ID, 'profile_photo': filePath})
    return
